import { routerGetter } from '../../../../utils/router';

Component({
    properties: {
        list: {
            type: Array,
            observer: function (newVal, oldVal) {
                this.cleanData();
            }
        }
    },
    data: {
        coursesList: []
    },
    methods: {
        /** 清理页面需要展示的数据 */
        cleanData: function (params) {
            let _props = this.properties;
            this.setData({
                coursesList: _props.list.map(item => {
                    return item;
                })
            });
        },
        goPage: function (e) {
            let dataset = e.currentTarget.dataset;
            if (dataset.uri) {
                routerGetter().execute(dataset.uri);
            } else {
                wx.navigateTo({
                    url: `/pages/detail/detail?courseId=${dataset.courseId}`
                });
            }
        }
    }
});
